#include <iostream>
#include <cstring>
using namespace std;
int main(){
    long long n;
    while (cin >> n){
        for(long long i = 1;i <=n; i++){
            long long a,b;
            cin >> a >> b;
            long long ans = 0,flag = 0;
            while (a>b){
                a = a-a%(a/2+1);
                ans++;
            }
            cout<<"Case "<<i<<":"<<" "<<ans<<endl;
        }
    }

    return 0;
}